package com.zyx.controller;

import com.zyx.pojo.Headline;
import com.zyx.service.HeadlineService;
import com.zyx.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("headline")
public class HeadlineController {
    @Autowired
    private HeadlineService headlineService;

    @PostMapping("publish")
    public Result publish(@RequestHeader String token, @RequestBody Headline headline) {
        return headlineService.publish(token, headline);
    }

    @PostMapping("findHeadlineByHid")
    public Result findHeadlineByHid(Integer hid) {
        return headlineService.findHeadlineByHid(hid);
    }

    @PostMapping("updateData")
    public Result updateData(@RequestBody Headline headline){
        return headlineService.updateData(headline);
    }

    @PostMapping("removeByHid")
    public Result deleteData(Integer hid){
        return headlineService.removeByHid(hid);
    }

}
